package controller;

import dao.ProductMsgDao;
import pojo.product.ProductMsgEntity;

import java.io.IOException;

/**
 * @author Limohan
 */
public class ProductMsgController {
    private final ProductMsgDao productMsgDao = new ProductMsgDao();
    private static final ProductMsgController productMsgController = new ProductMsgController();
    private ProductMsgController(){}

    public static ProductMsgController getInstance(){
        return productMsgController;
    }

    //新增
    public String addMsg(ProductMsgEntity productMsgEntity) throws IOException {
        productMsgEntity.setId("1");
        String id =productMsgDao.getMaxId();
        productMsgEntity.setId(id);
        if(productMsgDao.isProduct(productMsgEntity.getType())){
            productMsgDao.saveMsg(productMsgEntity);
            return "添加成功";
        }
        return "没有此类型的商品";
    }
}
